
import dayjs from 'dayjs'

/**
 * 时间字典
 */
export const timeDictionary = (_data: number) => {
  return _data ? dayjs(_data * 1000).format("YYYY-MM-DD HH:mm:ss") : "----"
}

/**
 * 结束时间 + 86399秒
 */
export const endTimePlus = (_start: any, _end: any) => {
  const time = _start ? (_end ? Number(_end) + 86399 : dayjs().unix()) : ''
  return time
}

/**
 * 售后订单状态
 */
export const afterSalesOrderStatusText = (_type: number, _status: number) => {
  let text = ''
  if (_type == 1) {
    switch (Number(_status)) {
      case 1:
        text = '退款待审核'
        break;
      case 2:
        text = '取消退款售后'
        break;
      case 3:
      case 4:
        text = '退款已处理，等待到账'
        break;
      case 5:
        text = '退款失败'
        break;
      case 6:
      case 7:
        text = '退款成功'
        break;
      case 8:
        text = '退货待审核'
        break;
      case 9:
        text = '取消退货售后'
        break;
      case 10:
        text = '同意退货待买家上传快递单号'
        break;
      case 11:
        text = '买家已上传单号，待卖家审核'
        break;
      case 12:
      case 13:
        text = '退货已处理，等待到账'
        break;
      case 14:
        text = '退货失败'
        break;
      case 15:
      case 16:
        text = '退货成功'
        break;
      case 17:
        text = '换货待审核'
        break;
      case 18:
        text = '取消换货售后'
        break;
      case 19:
        text = '同意换货待买家上传快递单号'
        break;
      case 20:
        text = '买家已上传单号，待卖家审核'
        break;
      case 21:
        text = '卖家已上传换货单号'
        break;
      case 22:
      case 23:
        text = '换货已处理，等待到账'
        break;
      case 24:
        text = '换货失败'
        break;
      case 25:
      case 26:
      case 36:
        text = '换货成功'
        break;
      case 27:
        text = '补发待审核'
        break;
      case 28:
        text = '取消补发售后'
        break;
      case 29:
        text = '同意补发，待卖家上传单号'
        break;
      case 30:
        text = '卖家已上传补单单号'
        break;
      case 31:
      case 32:
        text = '补发已处理，等待到账'
        break;
      case 33:
        text = '补发失败'
        break;
      case 34:
      case 35:
      case 37:
        text = '补发成功'
        break;
      default:
        text = '订单未知状态'
        break;
    }
  } else {
    switch (Number(_status)) {
      case 1:
        text = '退款维权待审核'
        break;
      case 2:
        text = '取消退款维权'
        break;
      case 3:
      case 4:
        text = '退款维权已处理，等待到账'
        break;
      case 5:
        text = '退款维权失败'
        break;
      case 6:
      case 7:
        text = '退款维权成功'
        break;
      case 8:
        text = '退货维权待审核'
        break;
      case 9:
        text = '取消退货维权'
        break;
      case 10:
      case 11:
        text = '退货维权已处理，等待到账'
        break;
      case 12:
        text = '退货维权失败'
        break;
      case 13:
      case 14:
        text = '退货维权成功'
        break;
      case 15:
        text = '换货维权待审核'
        break;
      case 16:
        text = '取消换货维权'
        break;
      case 17:
      case 18:
        text = '换货维权已处理，等待到账'
        break;
      case 19:
        text = '换货维权失败'
        break;
      case 20:
      case 21:
        text = '换货维权成功'
        break;
      case 22:
        text = '补发维权待审核'
        break;
      case 23:
        text = '取消补发维权'
        break;
      case 24:
      case 25:
        text = '补发维权已处理，等待到账'
        break;
      case 26:
        text = '补发维权失败'
        break;
      case 27:
      case 28:
        text = '补发维权成功'
        break;
      default:
        text = '订单未知状态'
        break;
    }
  }
  return text
}

/**
 * 售后记录
 */
export const afterSalesOrderDescri = (_type: number, _status: number, _price: string = '0') => {
  let text = ''
  if (_type == 1) {
    switch (_status) {
      case 1:
        text = '买家申请退款'
        break;
      case 2:
        text = '卖家改为退款'
        break;
      case 3:
      case 4:
        text = '卖家同意退款，退款中'
        break;
      case 5:
        text = `卖家同意退款，退部分款，退款金额【${_price}】`
        break;
      case 6:
        text = `卖家同意退款，退全款，退款金额【${_price}】`
        break;
      case 7:
        text = '卖家同意，不退款'
        break;
      case 8:
        text = '卖家拒绝退款'
        break;
      case 9:
        text = '买家申请退货'
        break;
      case 10:
        text = '卖家改为退货'
        break;
      case 11:
        text = '卖家同意退货，买家待上传快递单号'
        break;
      case 12:
        text = '卖家同意退货，买家已上传快递单号'
        break;
      case 13:
      case 14:
        text = '卖家同意退货，退款中'
        break;
      case 15:
        text = `卖家同意退货，退部分款，退款金额【${_price}】`
        break;
      case 16:
        text = `卖家同意退货，退全款，退款金额【${_price}】`
        break;
      case 17:
        text = '卖家同意退货，不退款'
        break;
      case 18:
        text = '卖家拒绝退货'
        break;
      case 19:
        text = '买家申请换货'
        break;
      case 20:
        text = '卖家改为换货'
        break;
      case 21:
        text = '卖家同意换货，买家待上传快递单号'
        break;
      case 22:
        text = '卖家同意换货，买家已上传快递单号'
        break;
      case 23:
        text = '卖家同意换货，卖家已上传快递单号'
        break;
      case 24:
      case 25:
        text = '卖家同意换货，退款中'
        break;
      case 26:
        text = `卖家同意换货，退部分款，退款金额【${_price}】`
        break;
      case 27:
        text = `卖家同意换货，退全款，退款金额【${_price}】`
        break;
      case 28:
        text = '卖家同意换货，不退款'
        break;
      case 29:
        text = '卖家拒绝换货'
        break;
      case 30:
        text = '买家申请补单'
        break;
      case 31:
        text = '卖家改为补单'
        break;
      case 32:
        text = '卖家同意补发，卖家待上传快递单号'
        break;
      case 33:
        text = '卖家同意补发，卖家已上传快递单号'
        break;
      case 34:
      case 35:
        text = '卖家同意补发，退款中'
        break;
      case 36:
        text = `卖家同意补发，退部分款，退款金额【${_price}】`
        break;
      case 37:
        text = `卖家同意补发，退全款，退款金额【${_price}】`
        break;
      case 38:
        text = '卖家同意补发，不退款'
        break;
      case 39:
        text = '卖家拒绝补发'
        break;
      default:
        text = '描述错误'
        break;
    }
  } else {
    switch (_status) {
      case 1:
        text = '买家申请退款维权'
        break;
      case 8:
        text = '买家申请退货维权'
        break;
      case 15:
        text = '买家申请换货维权'
        break;
      case 22:
        text = '买家申请补单维权'
        break;
      case 2:
      case 3:
      case 9:
      case 10:
      case 16:
      case 17:
      case 23:
      case 24:
        text = '卖家同意维权，退款中'
        break;
      case 4:
      case 11:
      case 18:
      case 25:
        text = `卖家同意维权，退部分款，退款金额【${_price}】`
        break;
      case 5:
      case 12:
      case 19:
      case 26:
        text = `卖家同意维权，退全款，退款金额【${_price}】`
        break;
      case 6:
      case 13:
      case 20:
      case 27:
        text = '卖家同意维权，不退款'
        break;
      case 7:
      case 14:
      case 21:
      case 28:
        text = '卖家拒绝维权'
        break;
      default:
        text = '描述错误'
        break;
    }
  }
  return text
}

/**
 * 货款结算状态
 */
export const paymentGoodsStatusText = (_status: number) => {
  switch (_status) {
    case 0:
      return '待提现'
    case 1:
      return '已申请'
    case 2:
      return '提现成功'
    default:
      return '未知状态'
  }
}

/**
 * 货款打款状态
 * 打款状态0：未打款 P1000：交易成功；P2000：交易失败；P3000：结果未知；P3001:处理中。
 */
export const paymentStatusText = (_status: any) => {
  switch (_status) {
    case '0':
    case 'P3001':
    case 'P3002':
      return '打款中'
    case 'P1000':
      return '打款成功'
    case 'P2000':
      return '打款失败'
    default:
      return '未知状态'
  }
}

/**
 * 单位用户导入文件状态
 * 状态 0:待读取 1：已读取
 */
export const unitUserFileStatusText = (_status: any) => {
  switch (_status) {
    case 0:
      return '待读取'
    case 1:
      return '已读取'
    default:
      return '未知状态'
  }
}

/**
 * 单位用户导入文件每一行状态
 * 状态 0:待读取 1：已读取
 */
export const unitUserFileStatusText1 = (_status: any) => {
  switch (_status) {
    case 0:
      return '待运行'
    case 1:
      return '成功'
    case 2:
      return '失败'
    default:
      return '未知状态'
  }
}

/**
 * 分销商提现-审核状态
 * 状态：1待审核，2审核通过打款中，3审核拒绝，4打款成功，5打款失败
 */
export const distributorWithdrawalStatusText = (_status: any) => {
  switch (_status) {
    case 1:
      return '待审核'
    case 2:
      return '打款中'
    case 3:
      return '审核拒绝'
    case 4:
      return '打款成功'
    case 5:
      return '打款失败'
    default:
      return '未知状态'
  }
}